home *** CD-ROM | disk | FTP | other *** search
- Subject: v24i083: Qterm5.0 -- Query terminal for its type, Part02/02
- Newsgroups: comp.sources.unix
- Approved: rsalz@uunet.UU.NET
- X-Checksum-Snefru: a109e85b c0cdcc42 257a9ca3 4a7b89af
-
- Submitted-by: "Michael A. Cooper" <mcooper@usc.edu>
- Posting-number: Volume 24, Issue 83
- Archive-name: qterm5.0/part02
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: Makefile qterm.1 qterm.h qtermtab
- # Wrapped by rsalz@litchi.bbn.com on Fri Mar 22 12:25:38 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 2 (of 2)."'
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(1908 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- X#
- X# Copyright (c) 1990 Michael A. Cooper.
- X# This software may be freely distributed provided it is not sold for
- X# profit and the author is credited appropriately.
- X#
- X# $Header: /src/common/usc/bin/qterm/RCS/Makefile,v 5.1 1991/02/20 02:31:50 mcooper Exp $
- X#
- X# Makefile for QTerm
- X#
- X
- X#
- X# DIR is the main/top-level directory.
- X# If you change DIR, run "make reconfig".
- X#
- XDIR = /usr/usc
- X
- X#
- X# BIN is were the "qterm" binary gets installed.
- X#
- XBIN = $(DIR)/bin
- X
- X#
- X# MAN is the directory where the "qterm.1" man page goes.
- X#
- XMAN = $(DIR)/man/man1
- X
- X#
- X# TABFILE should be set to the location you want the qterm table
- X# file placed in.
- X#
- XTABFILE = $(DIR)/lib/qtermtab
- X
- X#
- X# Add "-DUSG5" to DEFS below, if your system is Unix System V.
- X# Add "-DHAS_VARARGS" if your system supports varargs.
- X# Add "-DOPT_COMPAT" if you want compatibility with old command line options.
- X#
- XDEFS = -DTABFILE=\"$(TABFILE)\" -DOPT_COMPAT
- X
- X#
- X# On some System V systems you will need to add "-lPW" to LIBS.
- X#
- XLIBS =
- X
- X
- XCONFIGFILES = Makefile qterm.1 options.3
- XCFILES = qterm.c options.c
- XHFILES = qterm.h options.h
- XOBJS = qterm.o options.o
- XCFLAGS = -O $(DEFS)
- X
- X
- Xqterm: $(OBJS) $(HFILES)
- X $(CC) $(CFLAGS) $(OBJS) -o qterm $(LIBS)
- X
- Xreconfig:
- X -@for i in $(CONFIGFILES); do \
- X echo ReConfiguring $$i...;\
- X sed "s;/usr/usc;$(DIR);g" < $$i > $$i.tmp;\
- X mv -f $$i.tmp $$i;\
- X done
- X
- X$(OBJS): $(HFILES)
- X
- Xshar:
- X shar README qtermtab $(CONFIGFILES) $(CFILES) $(HFILES) > qterm.shar
- X
- Xclean:
- X rm -f *.o core log *~ \#* qterm qterm.shar o
- X
- X#
- X# Install target for BSD machines.
- X#
- Xinstall: qterm qterm.1 qtermtab
- X install -c -m 755 qterm $(BIN)
- X install -c -m 644 qterm.1 $(MAN)
- X install -c -m 644 qtermtab $(TABFILE)
- X
- X#
- X# Install target for System V machines.
- X#
- Xinstall.usg5: qterm qterm.1 qtermtab
- X cp qterm $(BIN); chmod 755 $(BIN)/qterm
- X cp qterm.1 $(MAN); chmod 644 $(MAN)/qterm.1
- X cp qtermtab $(TABFILE); chmod 644 $(TABFILE)
- END_OF_FILE
- if test 1908 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'qterm.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'qterm.1'\"
- else
- echo shar: Extracting \"'qterm.1'\" \(5805 characters\)
- sed "s/^X//" >'qterm.1' <<'END_OF_FILE'
- X.\"
- X.\" Copyright (c) 1990 Michael A. Cooper.
- X.\" This software may be freely distributed provided it is not sold for
- X.\" profit and the author is credited appropriately.
- X.\"
- X.\" $Header: /am/sol/src/common/usc/bin/qterm/RCS/qterm.1,v 5.0 90/12/15 18:30:38 mcooper Release $
- X.\"
- X.TH QTERM 1 "6 November 1990"
- X.ds ]W USC-UCS
- X.SH NAME
- Xqterm \- Query Terminal
- X.SH SYNOPSIS
- Xqterm
- X[
- X.B +|\-alt
- X] [
- X.B +|\-always
- X] [
- X.B +|\-longname
- X] [
- X.B +|\-quiet
- X] [
- X.B +|\-sent
- X] [
- X.B +|\-timeout
- X] [
- X.B +|\-usrtab
- X] [
- X.B +|\-watch
- X] [
- X.B +|\-systab
- X] [
- X.B \-wait
- X.I interval
- X] [
- X.B \-file
- X.I tabfile
- X]
- X.SH DESCRIPTION
- X.I Qterm
- Xis used to query a terminal to determine its name.
- XThis is done by sending a special sequence to the terminal,
- Xreading in a response, and comparing it against a table of possible
- Xresponses.
- XThe ``name'' printed to standard output should be one found in
- Xthe
- X.I termcap(5)
- X(or
- X.I terminfo(5)
- Xfor System V systems)
- Xdatabase.
- X.PP
- XFor
- X.I csh(1)
- Xusers,
- Xputting a line in your
- X.I .login
- Xfile such as:
- X.sp 1
- X.in +.5i
- Xsetenv TERM `qterm`
- X.in -.5i
- X.sp 1
- Xshould automagically set your terminal type.
- XFor
- X.I sh(1)
- Xusers, putting these lines in your
- X.I .profile
- Xfile should set your terminal type:
- X.sp 1
- X.in +.5i
- XTERM=`qterm`
- X.br
- Xexport TERM
- X.in -.5i
- X.sp 1
- X.LP
- XBy default,
- X.B qterm
- Xuses the system tab file
- X.I /usr/usc/lib/qtermtab
- Xto obtain information for querying terminals.
- X.SH OPTIONS
- X.IP \fB+alt\fP
- XUse the alternate string ``<ESCAPE>[c'' when asking the terminal to
- Xidentify itself. This string is recognized by most ANSI compatible
- Xterminals.
- X.IP \fB\-alt\fP
- XDon't use the alternate string, but the string found in the
- X.B tabfile
- Xbeing used.
- XThis is the default.
- X.IP \fB+always\fP
- XAlways send the terminal query string.
- XNormally the query string is only sent if it differs from
- Xthe last string sent.
- X.IP \fB-always\fP
- XOnly send the terminal query string if it differs from the last
- Xstring sent.
- XThis is the default.
- X.IP "\fB\-file \fItabfile\fP"
- XUse
- X.I <tabfile>
- Xto find information for querying the terminal.
- X.IP \fB+longname\fP
- XPrint only the long (verbose) terminal name.
- X.IP \fB\-longname\fP
- XDon't print the long (verbose) terminal name.
- XThis is the default.
- X.IP \fB+quiet\fP
- XBe quiet and only print the terminal name to standard output.
- X.IP \fB\-quiet\fP
- XDon't be quiet and only print the terminal name to standard output.
- XThis is the default.
- X.IP \fB+watch\fP
- XWatch the characters sent and recieved to the terminal.
- X.IP \fB\-watch\fP
- XDon't watch the characters sent and recieved to the terminal.
- XThis is the default.
- X.IP \fB+timeout\fP
- XWait for timeout when listening for response string.
- XThis is useful if the first entry in a qtermtab doesn't have
- Xa response string with an ending character that is common
- Xwith the rest of the qtermtab entries.
- X.IP \fB\-timeout\fP
- XDisable waiting for timeout when listening for response string.
- XThis is the default.
- X.IP \fB+usrtab\fP
- XUse
- X.B $HOME/.qtermtab
- Xto find information for querying the terminal.
- X.IP \fB\-usrtab\fP
- XDon't use
- X.B $HOME/.qtermtab
- Xto find information for querying the terminal.
- XThis is the default.
- X.IP \fB+sent\fP
- XDisplay the final response sent from
- Xthe terminal in a ``nice'' fashion.
- X.IP \fB-sent\fP
- XDon't display the final response sent from the terminal.
- XThis is the default.
- X.IP \fB+systab\fP
- XUse
- X.B /usr/usc/lib/qtermtab
- Xto find information for querying the terminal.
- XThis is the default
- X.IP \fB\-systab\fP
- XDon't use
- Xsystem tab file
- Xto find information for querying the terminal.
- X.IP "\fB\-wait \fIinterval\fP"
- XSet the wait (timeout) period to
- X.I interval
- X(in seconds).
- X.SH "QTERMTAB"
- XThe format of the file
- X$HOME/.qtermtab
- Xand
- X.I qterm's
- Xsystem tab file
- X.I /usr/usc/lib/qtermtab,
- Xconsists of four fields each seperated by white space (tabs and/or spaces).
- XThe first field is the string that should be used to query the terminal.
- XThe second field is the string to expect in response to the query.
- XThe third field is the terminal name (compatible with
- X.I termcap(5))
- Xto print to standard output.
- XThe fourth field is optional and may contain a description of the exact
- Xmanufacturer and model name of the terminal to be used in a message
- Xprinted to standard error.
- X.PP
- XBlank lines or lines starting with the character ``#''
- Xare ignored and may be used as comment lines.
- XA character preceeded by a ``^'' is taken to mean the
- X.I control
- Xcharacter. (i.e. ``^['' is interpretted as an <ESCAPE>).
- XBoth the send and receive (first and second) fields may contain
- Xoctal values preceeded by a `\\'.
- X(i.e. <ESCAPE> can be represented by `\\033'.)
- X.PP
- XThe ``expect'' (second) field
- Xcan be a regular expression denoted by a leading backslash (`\\').
- Xi.e. "^[[123" matches the string "^[[123", whereas "^[\\[123]" matches
- X"^[1" or "^[2" or "^[3".
- XSee
- X.I ed(1)
- Xfor regular expression information.
- X.PP
- XBelow is a sample file:
- X.sp 2
- X.nf
- X #
- X # QTerm File
- X #
- X ^[Z\0\0\0\0\0^[[?1;1c\0\0\0\0\0vt100\0\0\0\0\0A vt100 with STP
- X ^[Z\0\0\0\0\0^[[?1;2c\0\0\0\0\0vt100\0\0\0\0\0ANSI/VT100 Clone
- X ^[Z\0\0\0\0\0^[[?1;3c\0\0\0\0\0vt100\0\0\0\0\0A vt100 with AVO and STP
- X ^[Z\0\0\0\0\0^[[?1;4c\0\0\0\0\0vt100\0\0\0\0\0A vt100 with GPO
- X ^[Z\0\0\0\0\0^[iBO\0\0\0\0\0\0\0\0z29\0\0\0\0\0\0\0Zenith in Zenith Mode
- X.fi
- X.sp
- X.SH AUTHOR
- XMichael A. Cooper,
- X.br
- XUniversity Computing Services,
- X.br
- XUniversity of Southern California.
- X.SH FILES
- X.ta \w'/usr/usc/lib/qtermtab\ \ \ 'u
- X/usr/usc/lib/qtermtab \- System table
- X.br
- X$HOME/.qtermtab \- User's table
- X.br
- X/etc/termcap \- termcap(5) database
- X.SH SEE ALSO
- Xcsh(1), ed(1), sh(1), termcap(5)
- X.SH DIAGNOSTICS
- X.IP "\fITerminal not recognized - defaults to dumb.\fP"
- X.I QTerm
- Xdid not receive a response from the terminal, or the response
- Xdid not match any that
- X.I qterm
- Xhas stored internally. Use the \+watch option to check to see which
- Xis the case.
- X.SH BUGS
- XMany terminals do not send a response at all.
- END_OF_FILE
- if test 5805 -ne `wc -c <'qterm.1'`; then
- echo shar: \"'qterm.1'\" unpacked with wrong size!
- fi
- # end of 'qterm.1'
- fi
- if test -f 'qterm.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'qterm.h'\"
- else
- echo shar: Extracting \"'qterm.h'\" \(3281 characters\)
- sed "s/^X//" >'qterm.h' <<'END_OF_FILE'
- X/*
- X * Copyright (c) 1990 Michael A. Cooper.
- X * This software may be freely distributed provided it is not sold for
- X * profit and the author is credited appropriately.
- X */
- X
- X/*
- X * $Header: /src/common/usc/bin/qterm/RCS/qterm.h,v 5.1 1991/03/12 00:46:24 mcooper Exp $
- X *------------------------------------------------------------------
- X *
- X * $Source: /src/common/usc/bin/qterm/RCS/qterm.h,v $
- X * $Revision: 5.1 $
- X * $Date: 1991/03/12 00:46:24 $
- X * $State: Exp $
- X * $Author: mcooper $
- X * $Locker: $
- X *
- X *------------------------------------------------------------------
- X *
- X * Michael A. Cooper
- X * Research and Development Group
- X * University Computing Services
- X * University of Southern California
- X * (mcooper@usc.edu)
- X *
- X *------------------------------------------------------------------
- X * $Log: qterm.h,v $
- X * Revision 5.1 1991/03/12 00:46:24 mcooper
- X * - Changed CMASK to CHAR_CMASK to avoid conflict
- X * under AIX 3.1.
- X * - Expand tabs.
- X *
- X * Revision 5.0 1990/12/15 18:30:45 mcooper
- X * Version 5.
- X *
- X * Revision 4.1 90/12/15 18:14:27 mcooper
- X * Add copywrite.
- X *
- X * Revision 4.0 88/03/08 19:31:23 mcooper
- X * Version 4.
- X *
- X * Revision 3.2 88/03/08 19:28:52 mcooper
- X * Major rewrite.
- X *
- X * Revision 3.1 88/03/08 15:32:16 mcooper
- X * Changed around user's qtermtab
- X * file names.
- X *
- X * Revision 3.0 87/06/30 19:09:04 mcooper
- X * Release of version 3.
- X *
- X * Revision 2.4 87/06/30 19:02:28 mcooper
- X * WAIT changed to 2 for slow systems.
- X *
- X *------------------------------------------------------------------
- X */
- X
- X
- X
- X#ifndef TABFILE
- X# define TABFILE "/usr/local/lib/qtermtab" /* Default qtermtab file */
- X#endif
- X#define USRFILE ".qtermtab" /* User's qtermtab file */
- X#define OLDUSRFILE ".qterm" /* Old user qtermtab file */
- X#define ALTSEND "\033[c" /* Alternate query string */
- X#define WAIT 2 /* Timeout (in seconds) */
- X#define SIZE 512 /* Receive buffer size */
- X#define CHAR_MASK 0377 /* Character mask */
- X#define ESC '\033' /* ESCAPE */
- X
- X#ifdef TRUE
- X#undef TRUE
- X#endif
- X#ifdef FALSE
- X#undef FALSE
- X#endif
- X#define TRUE 1
- X#define FALSE 0
- X
- X#ifdef USG5
- X# define crmode() (_ntty.c_lflag &= ~ICANON,\
- X _ntty.c_cc[VMIN] = 1, _ntty.c_cc[VTIME] = 0,\
- X ioctl(_tty_ch, TCSETAF, &_ntty))
- X# define nocrmode() (_ntty.c_lflag |= ICANON,\
- X _ntty.c_cc[VMIN] = _otty.c_cc[VMIN],\
- X _ntty.c_cc[VTIME] = _otty.c_cc[VTIME],\
- X ioctl(_tty_ch, TCSETAF, &_ntty))
- X# define echo() (_ntty.c_lflag |= ECHO,\
- X ioctl(_tty_ch, TCSETAF, &_ntty))
- X# define noecho() (_ntty.c_lflag &= ~ECHO,\
- X ioctl(_tty_ch, TCSETAF, &_ntty))
- X#else /* !USG5 */
- X# define crmode() (_tty.sg_flags |= CBREAK,\
- X ioctl(_tty_ch, TIOCSETP, &_tty))
- X# define nocrmode() (_tty.sg_flags &= ~CBREAK,\
- X ioctl(_tty_ch, TIOCSETP, &_tty))
- X# define echo() (_tty.sg_flags |= ECHO, \
- X ioctl(_tty_ch, TIOCSETP, &_tty))
- X# define noecho() (_tty.sg_flags &= ~ECHO, \
- X ioctl(_tty_ch, TIOCSETP, &_tty))
- X#endif /* USG5 */
- X
- X/*
- X * Terminal table structure
- X */
- Xstruct termtable {
- X char *qt_sendstr; /* String to send to terminal */
- X char *qt_recvstr; /* String expected in response */
- X char *qt_termname; /* Terminal name */
- X char *qt_fullname; /* Full terminal name & description */
- X struct termtable *nxt; /* Next structure */
- X};
- Xstruct termtable *termtab = NULL;
- END_OF_FILE
- if test 3281 -ne `wc -c <'qterm.h'`; then
- echo shar: \"'qterm.h'\" unpacked with wrong size!
- fi
- # end of 'qterm.h'
- fi
- if test -f 'qtermtab' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'qtermtab'\"
- else
- echo shar: Extracting \"'qtermtab'\" \(3311 characters\)
- sed "s/^X//" >'qtermtab' <<'END_OF_FILE'
- X#
- X# $Header: /am/sol/src/common/usc/bin/qterm/RCS/qtermtab,v 5.0 90/12/15 18:30:49 mcooper Release $
- X#
- X# QtermTab - Query terminal table for qterm(1).
- X#
- X#SendStr ReceiveStr TermName FullTermName
- X#
- X^[Z ^[[?1;0c vt100 Base vt100
- X^[Z ^[[?1;1c vt100 vt100 with STP
- X^[Z ^[[?1;2c vt100 ANSI/VT100 Clone
- X^[Z ^[[?1;3c vt100 vt100 with AVO and STP
- X^[Z ^[[?1;4c vt100 vt100 with GPO
- X^[Z ^[[?1;5c vt100 vt100 with GPO and STP
- X^[Z ^[[?1;6c vt100 vt100 with GPO and AVO
- X^[Z ^[[?1;7c vt100 vt100 with GPO, STP, and AVO
- X^[Z ^[[?6;2c vt100 Uniterm vt100 Emulator
- X^[Z ^[/K h29 Zenith z29 in zenith mode
- X^[Z ^[/Z vt52 Generic vt52
- X^[Z ^[[0n vt100 AT&T Unix PC 7300
- X^[Z ^[[62;1;2;6;8c f220 Freedom 220 DEC clone
- X^[Z ^[[=1;1c avt-4p-s Concept with 4 pages memory
- X^[Z ^[[=1;2c avt-8p-s Concept with 8 pages memory
- X^[Z ^[[?10c la120 DEC Writer III
- X^[Z ^[[?12;7;0;102c vt125 DEC Pro 350 in vt125 mode
- X^[Z ^[[?12c vt100 Concept from Pro 350/UNIX
- X^[Z ^[[?1;11c cit101e CIE CIT-101 Enhanced w/Graphics
- X^[Z ^[[?62;1;2;6;7;8;9c vt220 DEC VT220
- X^[Z ^[[?62;1;2;6;7;8c vt100 Amiga Handshake
- X^[Z ^[[?62;1;4;6;7;8;9;15c vt200-sb Microvax II VMS
- X^[Z ^[[?63;1;2;6;7;8c tvi9220 TeleVideo 9220
- X^[Z ^[[?6c vt100 Generic vt100
- X^[Z ^[[?8;8;6c att630 AT&T 630 MTG
- X^[Z ^[[?8c vt100 TeleVideo 970
- X^[Z ^[[?;c vt100 Concept From Pro 350/UNIX
- X^[Z ^[[?l;0c vt100 AT&T Unix PC 7300
- X^[Z ^[iB0 h29 Zenith z29 in zenith mode
- X#^[Z ^[[?1;11c xt100+ Northern Tech LANPARSCOPE
- X############################################################################
- X#
- X# Enable at your own risk
- X#
- X#^[\040 50 wyse50 Wyse 50 Terminal
- X#^[i0 ^[iB0 z29 Zenith z29
- X#
- X# HP terminals
- X#
- X#^[*s1\^ 2621^J hp2621 Hewlett-Packard HP-2621
- X#^[*s1\^ 2621A^J hp2621a Hewlett-Packard HP-2621A
- X#^[*s1\^ 2621B^J hp2621b Hewlett-Packard HP-2621B
- X#^[*s1\^ 2621K^J hp2621k Hewlett-Packard HP-2621K
- X#^[*s1\^ 2621K45^J hp2621k45 Hewlett-Packard HP-2621K45
- X#^[*s1\^ 2621NL^J hp2621nl Hewlett-Packard HP-2621NL
- X#^[*s1\^ 2621NT^J hp2621nt Hewlett-Packard HP-2621NT
- X#^[*s1\^ 2621P^J hp2621p Hewlett-Packard HP-2621P
- X#^[*s1\^ 2621WL^J hp2621wl Hewlett-Packard HP-2621WL
- X#^[*s1\^ 2622^J hp2622 Hewlett-Packard HP-2622
- X#^[*s1\^ 2622A^J hp2622a Hewlett-Packard HP-2622A
- X#^[*s1\^ 2622P^J hp2622p Hewlett-Packard HP-2622P
- X#^[*s1\^ 2626^J hp2626 Hewlett-Packard HP-2626
- X#^[*s1\^ 2626A^J hp2626a Hewlett-Packard HP-2626A
- X#^[*s1\^ 2626P^J hp2626p Hewlett-Packard HP-2626P
- X#^[*s1\^ 2640^J hp2640 Hewlett-Packard HP-2640
- X#^[*s1\^ 2640A^J hp2640a Hewlett-Packard HP-2640A
- X#^[*s1\^ 2640B^J hp2640b Hewlett-Packard HP-2640B
- X#^[*s1\^ 2644A^J hp2644a Hewlett-Packard HP-2644A
- X#^[*s1\^ 2645^J hp2645 Hewlett-Packard HP-2645
- X#^[*s1\^ 2645A^J hp2645a Hewlett-Packard HP-2645A
- X#^[*s1\^ 2645NP^J hp2645np Hewlett-Packard HP-2645NP
- X#^[*s1\^ 2647^J hp2647 Hewlett-Packard HP-2647
- X#^[*s1\^ 2647A^J hp2647a Hewlett-Packard HP-2647A
- X#^[*s1\^ 2648^J hp2648 Hewlett-Packard HP-2648
- X#^[*s1\^ 2648A^J hp2648a Hewlett-Packard HP-2648A
- X############################################################################
- END_OF_FILE
- if test 3311 -ne `wc -c <'qtermtab'`; then
- echo shar: \"'qtermtab'\" unpacked with wrong size!
- fi
- # end of 'qtermtab'
- fi
- echo shar: End of archive 2 \(of 2\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked both archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-